package base.validation.annotation;

import base.validation.constraint.UniquenessValidator;

import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;

/**
 * Uniqueness
 *
 * @description: 根据classType 和 method 进行数据库唯一性校验
 *               唯一性校验方法参数类型必须和注解标记字段参数类型一致
 * @author: cyj
 * @date 2020 -10-19 16:18:26
 */
@Target({FIELD})
@Retention(RUNTIME)
@Constraint(validatedBy = UniquenessValidator.class)
public @interface Uniqueness {
    /**
     * Message string
     *
     * @return the string
     * @description:
     */
    String message() default "base.validation.annotation.uniqueness";

    /**
     * Class type class 校验类
     *
     * @return the class
     * @description:
     */
    Class<?> classType();

    /**
     * Method string 校验方法
     *
     * @return the string
     * @description:
     */
    String method();

    /**
     * Groups class [ ]
     *
     * @return the class [ ]
     * @description:
     */
    Class<?>[] groups() default {};

    /**
     * Payload class [ ]
     *
     * @return the class [ ]
     * @description:
     */
    Class<? extends Payload>[] payload() default {};

}
